﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace HARTCalibrationTool.Observers
{
    internal class TextBoxRetestUpdater : IObserver
    {
        private TextBox[] _textBoxArry;
        private TextBox _textBox;

        public TextBoxRetestUpdater(TextBox[] textBoxArry)
        {
            _textBoxArry = textBoxArry;
        }

        public void Update(List<string> listStr)
        {
            string[] strInfo;

            strInfo = listStr[0].Split('#');

            _textBox = _textBoxArry[int.Parse(strInfo[0])];

            if (_textBox.InvokeRequired)
            {
                _textBox.Invoke(new Action(() =>
                {
                    _textBox.AppendText(listStr[0] + Environment.NewLine);
                }));
            }
            else
            {
                _textBox.AppendText(listStr[0]);
            }
        }
    }
}
